import show_modal from './index.js'
  
const xt_show_modal = {
    install: (app, options) =>{
        const show_modal_fun = function(op={}){
            //#ifdef APP-PLUS
            return  new Promise((resolve, reject)=>{
               let moc = new show_modal({
                    ...op,
                    $event:function(e){
                        if(e.res){
                            resolve(e);
                        }else{
                            reject(e);
                        }
                     }
                })
                moc.show();
            })
            //#endif
             
            //#ifdef H5 || MP
                var promise=uni.showModal({
                    title: op.title,
                    content: op.content,
                    showCancel: !op.delCancel,
                    cancelText: op.cancelVal,
                    confirmText: op.confirmVal,
                });
                 
                return new Promise((resolve,reject)=>{
                    promise.then(data=>{
                        if(data.confirm){
                            resolve()
                        }
                    })
                })
                 
            //#endif
             
        }
        uni.$showModal = show_modal_fun
    }
};
  
export default xt_show_modal;